/**
 * @project heima-leadnews
 * @author MECHREVO
 * @date 2024/1/12 11:36:51
 * @version 1.0
 */
package com.heima.article.controller;

import com.heima.article.service.ApArticleService;
import com.heima.model.article.dto.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/api/v1/article")
public class ApArticleController {
    @Autowired
    private ApArticleService apArticleService;
    /**
     * 加载更首页
     *
     * @param articleHomeDto 文章首页dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/load")
    public ResponseResult load (@RequestBody ArticleHomeDto articleHomeDto){
        return apArticleService.load(articleHomeDto,1);
    }
    /**
     * 加载更多
     *
     * @param articleHomeDto 文章首页dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/loadmore")
    public ResponseResult loadmore (@RequestBody ArticleHomeDto articleHomeDto){
        return apArticleService.load(articleHomeDto,2);
    }
    /**
     * 加载最新
     *
     * @param articleHomeDto 文章首页dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/loadnew")
    public ResponseResult loadnew (@RequestBody ArticleHomeDto articleHomeDto){
        return apArticleService.load(articleHomeDto,1);
    }

    }
